
package nav;

import java.util.ArrayList;
import java.util.List;

public class StreetImpl implements Street {

	private String id;
	
	private String realname;
	
	private ArrayList<Coordinate> linePoints;
	
    public StreetImpl(String id, String realname) {
    	this.id = id;
    	this.realname = realname;
    	linePoints=new ArrayList<Coordinate>();
    }
    
    @Override
    public String getID(){
    	return id;
    }

    @Override
    public String toString(){
    	
    	String points="";
    	for (Coordinate c : linePoints) {
    		points += "X: " + c.getLong() + ", Y: " + c.getLat()+ ";   ";
			
		}
    	return id+", "+realname+", Points:   "+points;
    }

    @Override
    public String getRealName(){
    	return realname;
    }
        
    @Override
    public boolean hasLinePoint(Coordinate coordinate){
    	return linePoints.contains(coordinate);
    }

	@Override
	public void addLinePoint(Coordinate coordinate) {
		linePoints.add(coordinate);
	}

	@Override
	public Coordinate getLinePoint(int index) {
		return linePoints.get(index);
	}

	@Override
	public void addLinePoint(int index, Coordinate coordinate) {
		linePoints.add(index, coordinate);
	}

	@Override
	public int getLinePointSize() {
		return linePoints.size();
	}

	@Override
	public List<Coordinate> getLinePoints() {
		return linePoints;
	}
	
	@Override
	public List<Coordinate> getLinePointsBetweenCrossings(int startIndex, int goalIndex) {
		List<Coordinate> coordinates = new ArrayList<Coordinate>();
		if(startIndex > goalIndex){
			for(int i=startIndex;i>=goalIndex;i--){
				coordinates.add(linePoints.get(i));
			}
		}else{
			for(int i=startIndex;i<goalIndex+1;i++){
				coordinates.add(linePoints.get(i));
			}			
		}		
		return coordinates;
	}

	@Override
	public int createNewLinePoint(Coordinate nearestPoint) {
		throw new RuntimeException("Not Implemented");
	}

	@Override
	public int getLinePointEqualsPoint(Coordinate nearestPoint) {
		throw new RuntimeException("Not Implemented");
	}

	@Override
	public Coordinate getNearestPoint(Coordinate coordinate) {
		throw new RuntimeException("Not Implemented");
	}
}
